<!DOCTYPE html>
<!--
Copyright 2012 Mozilla Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
  <head>
    <meta charset="utf-8">
    <title>Required features testing for PDF.js</title>
    <style>
    body { font-family: sans-serif; }
    #tests { width: 920px; border-collapse:collapse; margin: 20px 0;  }
    #tests td, #tests th { border: 1px solid black; }
    .name { text-align: left; }
    .test, .emu, .impact, .area { text-align: center; }
    .test-Skipped { background-color: #C0C0C0; }
    .test-Success { background-color: #C0FFC0; }
    .test-Failed { background-color: #FFC0C0; }
    .test-Failed.emu-Yes { background-color: #FFFFC0; }
    </style>
    <style id="fontFaces">
    @font-face { font-family: 'plus'; src: url(data:font/opentype;base64,AAEAAAAOAIAAAwBgRkZUTWNJJVkAAAZEAAAAHEdERUYANQAkAAAGHAAAAChPUy8yVkDi7gAAAWgAAABgY21hcPAZ92QAAAHcAAABUmN2dCAAIQJ5AAADMAAAAARnYXNw//8AAwAABhQAAAAIZ2x5Zk7Cd0UAAANEAAAA8GhlYWT8fgSnAAAA7AAAADZoaGVhBuoD7QAAASQAAAAkaG10eAwCALUAAAHIAAAAFGxvY2EA5gCyAAADNAAAAA5tYXhwAEoAPQAAAUgAAAAgbmFtZWDR73sAAAQ0AAABnnBvc3RBBJyBAAAF1AAAAD4AAQAAAAEAAPbZ2E5fDzz1AB8D6AAAAADM3+BPAAAAAMzf4E8AIQAAA2sDJAAAAAgAAgAAAAAAAAABAAADJAAAAFoD6AAAAAADawABAAAAAAAAAAAAAAAAAAAABAABAAAABgAMAAIAAAAAAAIAAAABAAEAAABAAC4AAAAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAA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ABBAkABAAIAJ8AAwABBAkABQAgAK4AAwABBAkABgAIAOEATQBvAHoAaQBsAGwAYQAATW96aWxsYQAAcABsAHUAcwAAcGx1cwAATQBlAGQAaQB1AG0AAE1lZGl1bQAARgBvAG4AdABGAG8AcgBnAGUAIAAyAC4AMAAgADoAIABwAGwAdQBzACAAOgAgADEALQAxADIALQAyADAAMQAyAABGb250Rm9yZ2UgMi4wIDogcGx1cyA6IDEtMTItMjAxMgAAcABsAHUAcwAAcGx1cwAAVgBlAHIAcwBpAG8AbgAgADAAMAAxAC4AMAAwADAAIAAAVmVyc2lvbiAwMDEuMDAwIAAAcABsAHUAcwAAcGx1cwAAAAACAAAAAAAA/4MAMgAAAAEAAAAAAAAAAAAAAAAAAAAAAAYAAAABAAIAQwECAQMHdW5pRjAwMAd1bmlGMDMwAAAAAAAB//8AAgABAAAADgAAABgAIAAAAAIAAQABAAUAAQAEAAAAAgAAAAEAAAABAAAAAAABAAAAAMmJbzEAAAAAzN/V8gAAAADM3+A1); }
    </style>
    <script src="tests.js"></script>
  </head>
  <body>
    <h1>Required Features for PDF.js</h1>
    <div>User Agent: <span id="userAgent"></span></div>
    <script>
      document.getElementById('userAgent').innerHTML = navigator.userAgent;
    </script>

    <table id="tests">
      <caption>Tests Results</caption>
      <thead>
        <tr><th class="name">Name</th><th class="test">Test</th><th class="impact">Impact</th><th class="area">Area</th><th class="emu">Emulated</th><th></th></tr>
      </thead>
      <tbody id="output">
      </tbody>
    </table>
    <div id="canvasHolder" style="display: none;">
    </div>
    <div id="plusfontusage" style="font-family: plus; visibility: hidden;">`</div>

    <script>
    var wikiPageBase = 'https://github.com/mozilla/pdf.js/wiki/Required-Browser-Features#user-content-';
    var output = document.getElementById('output');
    // for some browser textContent is absent using innerHTML :/
    for (var i = 0; i < tests.length; i++) {
      var test = tests[i];
      var row = document.createElement('tr');
      row.id = 'test-results-' + test.id;
      var nameTd = document.createElement('td');
      nameTd.className = 'name';
      nameTd.innerHTML = test.name;
      row.appendChild(nameTd);
      var testTd = document.createElement('td');
      testTd.className = 'test';
      testTd.innerHTML = 'Running...';
      row.appendChild(testTd);
      var impactTd = document.createElement('td');
      impactTd.className = 'impact';
      impactTd.innerHTML = test.impact;
      row.appendChild(impactTd);
      var areaTd = document.createElement('td');
      areaTd.className = 'area';
      areaTd.innerHTML = test.area;
      row.appendChild(areaTd);
      var emulatedTd = document.createElement('td');
      emulatedTd.className = 'emu';
      row.appendChild(emulatedTd);
      output.appendChild(row);
      var infoTd = document.createElement('td');
      infoTd.className = 'emu';
      var infoA = document.createElement('a');
      infoA.href = wikiPageBase + test.id;
      infoA.innerHTML = 'info';
      infoTd.appendChild(infoA);
      row.appendChild(infoTd);
      output.appendChild(row);

      var publish = (function(row, testTd, emulatedTd) {
        return function (result) {
          row.className = 'test-' + result.output + ' emu-' + result.emulated;
          testTd.innerHTML = result.output;
          emulatedTd.innerHTML = result.emulated;
        };
      })(row, testTd, emulatedTd);

      var result;
      try {
        result = test.run();
      } catch (e) {
        console.error('test run failed: ' + e);
        result = { output: 'Failed', emulated: '?' };
      }
      if (result.then)
        result.then(publish);
      else
        publish(result);
    }
    </script>

  </body>
</html>
